<?php

class Ext_Article_Show_Family
{
    public $first;
    public $elliptical;
    public $prev;
    
    public function __construct($articleId)
    {
        $this->_build($articleId);
    }
    
    private function _build($articleId)
    {
        $article = App_Model_DbTable_Article::getInstance()->getRowById($articleId);
        if(!$article){
            return "";
        }
        
        if(!$article['firstReplyArticleId']){
            return "";
        }
        $firstArticle = App_Model_DbTable_Article::getInstance()->getRowById($article['firstReplyArticleId']);
        if(!$firstArticle){
            return "";
        }
        $this->first = new Ext_Article_Show($firstArticle['id']);
        $this->first->isExcerpt()->buildDescription()->buildAttachemnts()->buildTags();
        
        if(!$article['replyArticleId']){
            return "";
        }
        if($article['replyArticleId'] == $article['firstReplyArticleId']){
            return "";
        }
        $prevArticle = App_Model_DbTable_Article::getInstance()->getRowById($article['replyArticleId']);
        if(!$prevArticle){
            return "";
        }
        $this->prev = new Ext_Article_Show($prevArticle['id']);
        $this->prev->buildDescription();
        
        if(!$prevArticle['replyArticleId']){
            return "";
        }
        if($prevArticle['replyArticleId'] == $prevArticle['firstReplyArticleId']){
            return "";
        }
        $this->elliptical = new Ext_Article_Show($prevArticle['id']);
    }
}
